/**
 * Created on 11 avr. 08 by Sebastian Audet
 */
package grid;

/**
 * Defines an (x,y) location in a coordinate plane
 * @author Sebastian Audet
 */
public class Location implements Comparable<Location>{
    public int x = 0;
    public int y = 0;
    public Location(int x,int y)
    {
	this.x = x;this.y = y;
    }
    public int compareTo(Location o) {
	if(this.y>o.y)
	{
	    return 1;
	} else if (this.y==o.y)
	{
	    return xcomparison(this,o);
	}
	else
	{
	    return -1;
	}
    }
    
    private int xcomparison(Location one,Location two)
    {
	 if(one.x>two.x)
	    {
		return 1;
	    } else if (one.x == two.x) {
		return 0;
	    } else {
		return -1;
	    }
    }
    
    public String toString()
    {
	return "Location ("+x+","+y+")";
    }
}
